<?php
include ("headerPages.php");
?>
        
<script type="text/javascript">
function chkcontrol(j) {
    var total=0;
    for(var i=0; i < document.form.id1.length; i++){
        if(document.form.id1[i].checked){
            total =total +1;
        }
        if(total > 5){
            alert("Please Select only five!");
            document.form.id1[j].checked = false ;
            return false;
        }
    }
}

function chkcontroltwo(k) {
    var sum=0;
    for(var x=0; x < document.form.id2.length; x++){
        if(document.form.id2[x].checked){
            sum =sum +1;
        }
        if(sum > 5){
            alert("Please Select only five!");
            document.form.id2[k].checked = false ;
            return false;
        }
    }
}
</script>
        
<?php
//$table = "";
  //$classification = "";
  if(isset($_POST['Entrepreneur'])){
      $table = "entrepreneurForm";
      $formname = "Entrepreneur Form";
      $classification = "e"; // entrepreneur
  } else if(isset($_POST['Intern'])){
       $table = "studentForm";
       $formname = "Student Form";
       $classification = "i"; //intern
  } else if(isset($_POST['Consultant'])){
       $table = "consultantForm";
       $formname = "Consultant Form";
       $classification = "c"; //consultant
 }    

?>
       
<form name="form" action="Form.php" method="post">
   <div class="ex"><div class="marg">         
   <center><t><?php echo $formname;?></t></center> <br><br>
   
        <input type="hidden" name="table" value="<?php echo $table;?>"/>
        <input type="hidden" name="classification" value="<?php echo $classification;?>"/>
        <center>
        <color class="lblue">Create a login:  </color> <input class="text" type="text" name="login" size="57" maxlength="57"/> <br><br>
        <color class="lblue">Create password: </color> <input class="text" type="password" name="password" size="54" maxlength="54"/> <br><br>
        <color class="lblue">Retype password:  </color> <input class="text" type="password" name="passwordConfirmation" size="54" maxlength="54"/> &nbsp;&nbsp;<br><br>
        </center><br><br>
        <color class="lblue">First Name:</color> <input class="text" type="text" name="firstName" size="41" maxlength="41"/> &nbsp;&nbsp;
        <color class="lblue">Last Name:</color> <input class="text" type="text" name="lastName" size="100" maxlength="100"/><br><br>
        <color class="lblue">Address 1:</color>&nbsp; <input class="text" type="text" name="address1" size="166" maxlength="166"/><br><br>
        <color class="lblue">Address 2:</color>&nbsp; <input class="text" type="text" name="address2" size="166" maxlength="166"/><br><br>
        <color class="lblue">Zip Code:</color>&nbsp;&nbsp; <input class="text" type="text" name="zipCode" size="11" maxlength="11"/>&nbsp;&nbsp;
        <color class="lblue">City:</color> <input class="text" type="text" name="city" size="34" maxlength="34"/>&nbsp;&nbsp;
        <color class="lblue">State:</color> <input class="text" type="text" name="state" size="34" maxlength="34"/>&nbsp;&nbsp;
        <color class="lblue">Country:</color> <input class="text" type="text" name="country" size="34" maxlength="34"/><br><br>
        <color class="lblue">Email:</color> <input class="text" type="text" name="email" size="172" maxlength="172"/><br><br>
        <color class="lblue">University/College:</color> <input class="text" type="text" name="college" size="156" maxlength="156"/><br><br>
        <color class="lblue">Graduation date(MM/DD/YYYY):</color> <input class="text" type="text" name="graduation" size="59" maxlength="59"/>&nbsp;&nbsp;
        <color class="lblue">Major:</color> <input class="text" type="text" name="major" size="59" maxlength="59"/><br><br>
        <color class="lblue">Concentration:</color> <input class="text" type="text" name="concentration" size="162" maxlength="162"/><br>
        
        <div class="ex2">
            
            <div class="box">
                <color class="lblue"> Please choose 5 words to describe yourself in a work environment</color><br><br>
                <color class="green"><p><input type="checkbox" name="qualities[]" value="honest" id="id1" onclick="chkcontrol(0);" > honest &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="checkbox" name="qualities[]" value="driven" id="id1" onclick="chkcontrol(1);" > driven &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="checkbox" name="qualities[]" value="responsible" id="id1" onclick="chkcontrol(2);"> responsible</p> 
                <p><input type="checkbox" name="qualities[]" value="social" id="id1" onclick="chkcontrol(3);"> social &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="checkbox" name="qualities[]" value="dedicated" id="id1" onclick="chkcontrol(4);"> dedicated &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="checkbox" name="qualities[]" value="intelligent" id="id1" onclick="chkcontrol(5);"> intelligent </p> 
                <p><input type="checkbox" name="qualities[]" value="patient" id="id1" onclick="chkcontrol(6);"> patient &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="checkbox" name="qualities[]" value="reliable" id="id1" onclick="chkcontrol(7);"> reliable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="checkbox" name="qualities[]" value="friendly" id="id1" onclick="chkcontrol(8);"> friendly </p> 
                <p><input type="checkbox" name="qualities[]" value="achiever" id="id1" onclick="chkcontrol(9);"> achiever &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="checkbox" name="qualities[]" value="positive" id="id1" onclick="chkcontrol(10);"> positive &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="checkbox" name="qualities[]" value="organized" id="id1" onclick="chkcontrol(11);"> organized </p> 
                <p><input type="checkbox" name="qualities[]" value="energetic" id="id1" onclick="chkcontrol(12);"> energetic &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="checkbox" name="qualities[]" value="ambitious" id="id1" onclick="chkcontrol(13);"> ambitious &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="checkbox" name="qualities[]" value="bold" id="id1" onclick="chkcontrol(14);"> bold </p></color>
            
        </div></div>
        
        <div class="ex2">
            
            <div class="box">
                <color class="lblue"> Please choose 5 words to describe yourself in a work environment</color><br><br>
                <color class="green"><p><input type="checkbox" name="workEnv[]" value="Foreign" id="id2" onclick="chkcontroltwo(0);" > Foreign language study <br>
                <input type="checkbox" name="workEnv[]" value="Reading"  id="id2" onclick="chkcontroltwo(1);"> Reading <br>
                <input type="checkbox" name="workEnv[]" value="Writing"  id="id2" onclick="chkcontroltwo(2);"> Writing/blogging <br>
                <input type="checkbox" name="workEnv[]" value="Music" id="id2" onclick="chkcontroltwo(3);" > Music/musical instruments <br>
                <input type="checkbox" name="workEnv[]" value="Jogging" id="id2" onclick="chkcontroltwo(4);" > Jogging/walking <br>
                <input type="checkbox" name="workEnv[]" value="Horseback" id="id2" onclick="chkcontroltwo(5);" > Horseback riding <br>
                <input type="checkbox" name="workEnv[]" value="Yoga" id="id2" onclick="chkcontroltwo(6);" > Yoga &nbsp;&nbsp;&nbsp;<br>
                <input type="checkbox" name="workEnv[]" value="Team" id="id2" onclick="chkcontroltwo(7);" > Team sports: volleyball, bowling, soccer&nbsp;&nbsp;<br>
                <input type="checkbox" name="workEnv[]" value="Card" id="id2" onclick="chkcontroltwo(8);" > Card games <br>
                <input type="checkbox" name="workEnv[]" value="Video" id="id2" onclick="chkcontroltwo(9);" > Video Gaming <br>
                <input type="checkbox" name="workEnv[]" value="Fantasy" id="id2" onclick="chkcontroltwo(10);" > Fantasy Sports <br>
                <input type="checkbox" name="workEnv[]" value="Dinner" id="id2" onclick="chkcontroltwo(11);"" > Dinner or Movie club <br>
                <input type="checkbox" name="workEnv[]" value="Ballroom" id="id2" onclick="chkcontroltwo(12);" > Ballroom dancing <br>
                <input type="checkbox" name="workEnv[]" value="Volunteering" id="id2" onclick="chkcontroltwo(13);" > Volunteering <br>
                <input type="checkbox" name="workEnv[]" value="NeedleArts" id="id2" onclick="chkcontroltwo(14);" > Needle arts: embroidery <br>
                <input type="checkbox" name="workEnv[]" value="CrossStitch" id="id2" onclick="chkcontroltwo(15);" > Cross-stitch<br>
                <input type="checkbox" name="workEnv[]" value="Jewelry" id="id2" onclick="chkcontroltwo(16);" > Jewelry making <br>
                <input type="checkbox" name="workEnv[]" value="Drawing" id="id2" onclick="chkcontroltwo(17);" > Drawing/painting/photography <br>
                <input type="checkbox" name="workEnv[]" value="Pottery" id="id2" onclick="chkcontroltwo(18);" > Pottery<br>
                <input type="checkbox" name="workEnv[]" value="Antiques" id="id2" onclick="chkcontroltwo(19);" > Antiques <br>
                <input type="checkbox" name="workEnv[]" value="Decor" id="id2" onclick="chkcontroltwo(20);" > Decor  <br>
                <input type="checkbox" name="workEnv[]" value="Postcards" id="id2" onclick="chkcontroltwo(21);" > Postcards<br>
                <input type="checkbox" name="workEnv[]" value="Genealogy" id="id2" onclick="chkcontroltwo(22);" > Genealogy <br>
                <input type="checkbox" name="workEnv[]" value="Hiking" id="id2" onclick="chkcontroltwo(23);" > Hiking/letterboxing/geocaching <br>
                <input type="checkbox" name="workEnv[]" value="Bird"  id="id2" onclick="chkcontroltwo(24);"> Bird-watching <br>
                <input type="checkbox" name="workEnv[]" value="Hunting" id="id2" onclick="chkcontroltwo(25);" > Hunting/fishing<br>
                <input type="checkbox" name="workEnv[]" value="Cooking" id="id2" onclick="chkcontroltwo(26);" > Cooking/baking  <br>
                <input type="checkbox" name="workEnv[]" value="Knitting" id="id2" onclick="chkcontroltwo(27);" > Knitting <br>
                <input type="checkbox" name="workEnv[]" value="Quilting" id="id2" onclick="chkcontroltwo(28);" > Quilting  </color>
        
        </div></div>
        
        <div class="box">
            <color class="dblue">Please place the words in order (1-3) 1 being the most motivating:</color><br><br>
            <input class="text" type="text" name="Security" size="1" maxlength="1"/><color class="green">. &nbsp;  Security</color><br>
            <color class="lblue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Humans are driven, even Maslow agrees, to first fulfill basic needs, which include: 
food, shelter and safety. In the context of the workplace, security is identified by 
2 sub-factors: “compensation” and “job security.” If compensation needs are 
adequately met, then you can check this box. If it is not fully met, it is a source 
of motivation for people. If you want better performance, you may want to offer 
stronger incentives and bonus. Next…job security. Regardless of the shape that the 
economy is in, we are all motivated to work for a company that is thriving and not 
going under and motivated by knowing that our performance is adequate enough 
that we have job security. If your employees are getting paid enough and know 
they have job security, then you’ve met 2 of their 6 needs.</color><br><br>
            <input class="text" type="text" name="Identity" size="1" maxlength="1"/><color class="green">. &nbsp;  Identity</color><br>
            <color class="lblue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Humans are social creatures and driven by the need to “affiliate” with things they 
care about. Given that we spend most of our lifetime working, we are motivated 
by working for a company, department or team we feel proud to tell about friends 
and family about – a winning team. “How cool is it that Joe works for Facebook
or Twitter?” We want to have an affiliation for the companies and teams we work 
with and the change they are making in the world. The second sub-factor related 
to identity is “title.” Some of us are motivated by that next promotion to get the 
title that we deserve and to be recognized for that. It will become part of a new 
identity we strive to embody.</color><br><br>
            <input class="text" type="text" name="Stimulation" size="1" maxlength="1"/><color class="green">. &nbsp;  Stimulation</color><br>
            <color class="lblue">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Humans desire to be challenged and stimulated. In the workplace, we are looking 
for “new and exciting opportunities” that keep us engaged and stretch us to grow. 
Specifically, we like to work on new and cool projects/initiatives or to be put on 
task force that will change how we operate internally. Who doesn’t want to be on 
the project that will change the way we experience mobile apps? Chances are that 
some of your direct reports, particularly the ones who are high performers need 
that level of stimulation in order to stay engaged and continue their career with the 
company. The second factor related to stimulation is “mastery in a new domain.” 
We all want to learn new skills and gain mastery, and then move onto to learn 
something else. It not only keeps our skills fresh, but keeps us relevant and more 
marketable in the world of work. It is only when we have mastery over an area 
that we feel we are performing at our best and can have a sense of autonomy and 
not a need to rely on others nor be micromanaged.</color><br><br>
        <div>           
        </div>
        </div>      
       <center>
       <br>    
       <input class="button" name="submit" type="submit" value="Submit"/>
       <input class="button" name="cancel" type="button" onClick="window.location.href='index.php';" value="Cancel"></center> 
        </div></div></form>
<?php


if (isset($_POST['submit'])) {
    
        $table= $_POST['table'];
        $classification= $_POST['classification'];
        
        
        $qualities = $_POST['qualities'];     
        $workEnv = $_POST['workEnv'];  
        
        $login = $_POST['login'];
        $checkpass = $_POST['password'];
        $checkpassOK = $_POST['passwordConfirmation'];
        
        if (($checkpass != null) && ($checkpassOK != null) && ($checkpass == $checkpassOK)) 
            $password = $checkpass;
        else {
            $message = "Missing password or passwords are not the same";
            $password = null;
        }
        
        $firstName = $_POST['firstName'];
            if ($firstName == null) $miss = "First Name ";
        $lastName = $_POST['lastName'];
            if ($lastName == null) $miss = $miss."Last Name ";
        $address1 = $_POST['address1'];
            if ($address1 == null) $miss = $miss."Address 1 ";
        $address2 = $_POST['address2'];
        $zipCode = $_POST['zipCode'];
            if ($zipCode == null) $miss = $miss."Zip Code ";
        $city = $_POST['city'];
            if ($city == null) $miss = $miss."City ";
        $state = $_POST['state'];
            if ($state == null) $miss = $miss."State ";
        $country = $_POST['country'];  
            if ($country == null) $miss = $miss."Country ";
        $email = $_POST['email'];  
            if ($email == null) $miss = $miss."Email ";
        $college = $_POST['college'];  
            if ($college == null) $miss = $miss."College ";
        $graduation = $_POST['graduation'];  
            if ($graduation == null) $miss = $miss."Graduation ";
        $major = $_POST['major'];  
            if ($major == null) $miss = $miss."Major ";
        $concentration = $_POST['concentration'];  
            if ($concentration == null) $miss = $miss."Concentration ";
            if($miss != null) $message = $message . "Missing field(s): $miss ";
        $word1 = $qualities[0];
        $word2 = $qualities[1];
        $word3 = $qualities[2];
        $word4 = $qualities[3];
        $word5 = $qualities[4];
        if ($word1==null || $word2==null || $word3==null || $word4==null || $word5==null)
            $message = $message . "You have to choose 5 qualities to proceed ";
        
        $hobby1 = $workEnv[0];
        $hobby2 = $workEnv[1];
        $hobby3 = $workEnv[2];
        $hobby4 = $workEnv[3];
        $hobby5 = $workEnv[4];
        if ($hobby1==null || $hobby2==null || $hobby3==null || $hobby4==null || $hobby5==null)
            $message = $message . "You have to choose 5 hobbies to proceed ";
        $test1= $_POST['Security'];
        $test2= $_POST['Identity'];
        $test3= $_POST['Stimulation'];
        
        if((($test1>0) && ($test1<4)) && (($test2>0) && ($test2<4)) && (($test3>0) 
                && ($test3<4)) && ($test1 != $test2) && ($test2 != $test3) && ($test3 != $test1)){
            
            $Security = $test1;
            $Identity = $test2;
            $Stimulation = $test3;
        } else {
            $message = $message . 'You have to choose diferent numbers from 1 to 3!';
            $Security = NULL;
            $Identity = NULL;
            $Stimulation = NULL;
        }
        
        $con = mysqli_connect("localhost", "root", "root");
        //  $con = mysqli_connect("localhost", "root", "");
          if (mysqli_connect_errno($con))
            {
            echo "Failed to connect to MySQL: " . mysqli_connect_errno();
            }

          //mysqli_select_db($con,"alignedvisions");
  
        mysqli_select_db($con,"alignedvisions");
        
        if($login!= null && $password != null && $firstName!= null && $lastName!= null
                && $address1!= null && $zipCode!= null && $city!= null && $state!= null 
                && $country!= null && $email!= null && $college!= null && $graduation!= null
                && $major!= null && $concentration!= null &&  $word1!= null && $word2!= null
                && $word3!= null && $word4!= null && $word5!= null && $hobby1!= null
                && $hobby2!= null && $hobby3!= null && $hobby4!= null && $hobby5!= null
                && $Security!= null && $Identity!= null && $Stimulation!= null){
           
           // echo $classification;
            
            $sql1="INSERT INTO login (username, password, classification) 
              VALUES ('$login', '$password', '$classification')";
            
            $sql2="INSERT INTO $table(login, firstName, lastName, address1, address2, zipCode,
            city, state, country, email, college, graduation, major, concentration,
            word1, word2 ,word3, word4, word5, hobby1, hobby2, hobby3, hobby4, hobby5,
            Security, Identity, Stimulation, week, company) 
            VALUES ('$login', '$firstName','$lastName', '$address1','$address2', '$zipCode',
            '$city', '$state','$country', '$email', '$college','$graduation','$major','$concentration',
            '$word1','$word2','$word3','$word4','$word5', '$hobby1', '$hobby2', '$hobby3', '$hobby4',
            '$hobby5', '$Security','$Identity','$Stimulation','0', NULL)";
            
            echo $sql1;
            echo $sql2;
            
            $result1 = mysqli_query($con, $sql1);
            $result2 = mysqli_query($con, $sql2);
            
            $flag = 0;
            
            if ($result1 == FALSE || $result2 == FALSE){
                die ('ERROR: '. mysqli_connect_errno($con));
            }
            $message =  'Your registration was submited successfully!';
            $flag = 1;
        }
        
        if (flag == 1)
            echo "<script> alert('$message'); location.href = 'uploadVideo.php'; </script>";
        else
            echo "<script> alert('$message'); </script>";
        mysqli_close($con);
  }

include ("footerPages.php");
?>
